<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Dynamic_Component</title>
    <script src="../Vue.js"></script>
</head>
<body>

    <div id="app">

        <div id="content">
            <component :is="currentView"></component>
        </div>

        <button @click="ChangeIndex('First')">首页</button>
        <button @click="ChangeIndex('List')">列表</button>
        <button @click="ChangeIndex('News')">新闻</button>
        <button @click="ChangeIndex('Personal')">个人</button>
    </div>

    <script>
       let First = Vue.component('First',{
        	template:"<h1>首页内容展示</h1>"
        })

        let List = Vue.component('List',{
	        template:"<h1>列表内容展示</h1>"
        })

       let News = Vue.component('News',{
	       template:"<h1>新闻内容展示</h1>"
        })

       let Personal = Vue.component('Personal',{
	       template:"<h1>个人内容展示</h1>"
        })
        let app = new Vue({
            el:"#app",
            data:{
	            currentView:"First"
            },
            component:{
                First,List,News,Personal
            },
            methods:{
            	ChangeIndex:function (Tab) {
                    this.currentView = this.$options.component[Tab]
	            }
            }
        })
    </script>
</body>
</html>